define(['domReady', 'app/common/base', 'underscore'], function(domReady, base, score) {
    var env, appMap, app;
    env = (window.location.host.indexOf('dev') !== -1 || window.location.search.indexOf('dev') !== -1) ? new base('dev') : new base('live');
    domReady(function() {
        // 根据Url 动态加载需要的SAP
        appMap = {
            'admin_auth_login':'app/admin/auth/login',
            'staff_auth_login':'app/staff/auth/login',
        };
        // 检查Url
        var url = document.location.pathname;
        // 首页
        url = url === '/' ? 'default' : url.substr(1).replace(/\//g, '_');
        console.log('Your mapping Index is:%c ' + url, 'color:red;');
        if (_.has(appMap, url)) {
            app = _.property(url)(appMap);
            requirejs([app], function(pageApp) {
                if (_.indexOf(_.functions(pageApp), 'init') !== -1) {
                    pageApp.init.call(_.extend(env, pageApp));
                } else if (typeof(pageApp) === 'function') {
                    var f = new pageApp();
                    f.init.call(env);
                }
            });
        }
    });
});